﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZkSurvey.Common.SurveyMgr;
using ZkSurvey.DAL.SurveyMgr;

namespace ZkSurvey.BLL.SurveyMgr
{
    public class ParticipationBl
    {
        public void UpdateParticipation(Participation partic)
        {
            ParticipationDa.UpateParticipation(partic);
        }

        public Participation GetParticipation(int id)
        {
            return ParticipationDa.GetParticipation(id);
        }

        public int GetParticipationConut(int surveyId)
        {
            return ParticipationDa.GetParticipationList(null, surveyId).Count;
        }

        public int GetValidParticipationConut(int surveyId)
        {
            return ParticipationDa.GetParticipationList(null, surveyId).Count(p => (p.IsValid.HasValue && p.IsValid.Value));
        }

        public int GetInValidParticipationConut(int surveyId)
        {
            return ParticipationDa.GetParticipationList(null, surveyId).Count(p => (p.IsValid.HasValue && !p.IsValid.Value));
        }

        public int GetUndifiedParticipationConut(int surveyId)
        {
            return ParticipationDa.GetParticipationList(null, surveyId).Count(p => !p.IsValid.HasValue);
        }
    }
}
